package com.ocom.payhandle.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.payconfig.EntityDishesWhite;
import com.ocom.common.vo.pyhandle.MenuListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoDishesWhite extends BaseMapper<EntityDishesWhite> {


	/**
	 * select 	DW.id , DW.dishes_id , DW.state , DI.dishes_name , DI.dishes_code
	 * from 	dishes_white DW
	 * left join	dishes_info DI
	 * on		DI.com_id = DW.com_id 	and	DI.merch_id = DW.merch_id 	and	DI.dishes_id = DW.dishes_id
	 * where 	DW.com_id = @companyId	and 	DW.merch_id = @deviceInfo.menu_merch_id
	 * and 	DW.id > @deviceInfo.menu_add
	 * and 	( DW.state = 0 	or 	DW.id > @menuDelete 		)
	 * order by	id 	limit 	@listLimit
	 */

	@Select({"<script>",
			"select DW.id , DW.dishes_id , DW.state , DI.dishes_name , DI.dishes_code  \n" +
					"from dishes_white DW \n" +
					"left join dishes_info DI \n" +
					"on (DI.com_id = DW.com_id and DI.merch_id = DW.merch_id and DI.dishes_id = DW.dishes_id) " +
					"where  DW.com_id = #{comId} and  DW.merch_id = #{merchId} " +
					"and  DW.id > #{menuAdd}  \n" +
					"and  ( DW.state = 0  or  DW.id > #{menuDelete}   ) \n" +
					"ORDER BY id ASC  limit  #{listLimit} " +
					"</script>"})
	List<MenuListVo> getDishesList(@Param("comId")Long comId,
								 @Param("menuAdd")Integer menuAdd,
								 @Param("menuDelete")Integer menuDelete,
								 @Param("listLimit")Integer listLimit,
								 @Param("merchId")Integer merchId
								 );
}
